# -*- encoding: utf-8 -*-
"""
    package.module
    ~~~~~~~~~~~~~~

    测试的主入口

    :copyright: (c)  2018/9/26 by zwhset.
    :license: OPS, see LICENSE_FILE for more details.
"""
import sys

reload(sys)
sys.setdefaultencoding('utf8')


import unittest
import requests

ENV = "qa"
CLUSTER_NAME = "ops-test"
VERSION_NUMBER = "1.0.3.1"
NAMESPACE = "qb-qa-12"
PODS_NUMBER = 3

URL = "http://127.0.0.1:5000/api/{env}/{cluster_name}/deploy".format(
    env=ENV, cluster_name=CLUSTER_NAME
)

class TestDeploy(unittest.TestCase):
    """发布的测试用例"""

    def test_deploy(self):
        """测试发布"""
        data = dict(
            version_number=VERSION_NUMBER,
            namespace=NAMESPACE,
            pods_number=PODS_NUMBER
        )
        r = requests.post(URL, data=data)
        res = r.json()
        self.assertEqual(res.get('code', 0), 0, "测试发布时失败, message: {0} url: {1}, params: {2}".format(
            res.get("message", ""),
            URL,
            data))



if __name__ == "__main__":
    unittest.main()
